# 查找某元素在列表内的下标索引
mylist = ["itcast", "itheima", "python"]
index = mylist.index("python")
print(f"python在列表中的下标索引值是{index}")

# 修改特定下标索引的值
mylist[0] = "xiaoming"
print(mylist)

# 在指定下标位置插入新元素
mylist.insert(1, "best")
print(mylist)

# 在列表尾部增加单个元素
mylist.append("小红")
print(mylist)

# 在列表末尾追加一批元素
mylist2 = [1, 2, 3]
mylist.extend(mylist2)
print(mylist)

# 删除指定下标索引的元素
mylist = ["itcast", "itheima", "python"]
del mylist[0]
print(mylist)
mylist = ["itcast", "itheima", "python"]
element = mylist.pop(2)
print(f"通过pop方法取出元素后列表内容：{mylist},取出的元素是：{element}")

# 删除某元素在列表中的第一个匹配项
mylist = ["itcast", "itheima", "itheima", "python"]
mylist.remove("itheima")
print(f"通过remove方法移除元素后，列表的结果是：{mylist}")

# 清空列表内容
mylist.clear()
print(f"列表被清空了，结果是：{mylist}")

# 统计某元素在列表内的数量
mylist = ["itcast", "itheima", "itheima", "python"]
count = mylist.count("itheima")
print(f"在列表中共有{count}个itheima")

# 统计列表中总共有多少元素
count = len(mylist)
print(f"列表中共有{count}个元素")
